﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Aricie.DNN.Services.Url.FriendlyUrl.Moles;
using Aricie.DNN.Services.Url.FriendlyUrl;

namespace Aricie.FriendlierUrlProvider.Test.Mocks
{


    class FupMocks
    {

        private static MFriendlierUrlContext _fupContext;
        private static UrlProviderInfo _standardUrlRewriterProvider;

        public static FriendlierUrlContext FupContext
        {
            get
            {
                return _fupContext;
            }
        }

        public static UrlProviderInfo StandardUrlRewriterProvider
        {
            get
            {
                if (_standardUrlRewriterProvider == null)
                {
                    _standardUrlRewriterProvider = new UrlProviderInfo() { Name = "StandardUrlRewriterProvider", ProviderType = "Aricie.DNN.Services.Url.FriendlyUrl.StandardUrlRewriterProvider, Aricie.FriendlierUrlProvider" };
                }

                return _standardUrlRewriterProvider;
            }
        }

        public static void Mock()
        {
            _fupContext = new MFriendlierUrlContext(FriendlierUrlContext.Instance);
            FriendlierUrlConfig fupConfig = new FriendlierUrlConfig();
            FriendlierUrlSettings settings = new FriendlierUrlSettings();
            MFriendlierUrlContext.InstanceGet = () => _fupContext;
            MFriendlierUrlContext.ConfigGet = () => fupConfig;
            _fupContext.FriendlierUrlPortalSettingsGet = () => settings;
            _fupContext.NoCacheGet = () => true;
            _fupContext.FindModuleNameIDictionaryOfUrlParamStringInt32 = (param, tabid) => "DNN_HTML";
            fupConfig.AvailableUrlrewriters.Add("StandardUrlRewriterProvider", StandardUrlRewriterProvider);

            MProviderUrlGroup pug = new MProviderUrlGroup();

            pug.ProviderNamesGet = () => new List<string> { "StandardUrlRewriterProvider" };
        }

    }
}
